// fenxiao/tixianRecords/index.js
var app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    CurrentPage:1,
    items:[],
    loadingMoreHidden:1,
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.GetBrokerageList(this.data.CurrentPage);
  },
  //获取提现记录
  GetBrokerageList: function (CurrentPage){
    var that = this;
    wx.request({
      url: app.globalData.host + '/api/Distributor/GetBrokerageRequestList',
      data: {
        userId: app.globalData.userInfo.Uid,
        page: CurrentPage,
        itemsPerPage: 10
      },
      success: function (res) {
        console.log("提现记录");
        console.log(res);
        if (res.data.Code == 0) {
            var items = res.data.Data.Items
            console.log(items);
            if (that.data.CurrentPage != 1) {
              var preGoods = that.data.items
              items = preGoods.concat(items);
            }
            that.setData({
              items: items,
              loadingMoreHidden: res.data.Data.TotalPages
            })
        } else {
          wx.showModal({
            title: '错误',
            content: res.data.Message,
            showCancel: false
          })
        }
      }
    })
  },
  // 加载更多
  loadMore: function (e) {
    var that = this;
    if (that.data.loadingMoreHidden > 1 && that.data.CurrentPage < that.data.loadingMoreHidden){
      var currPage = that.data.CurrentPage;
      that.setData({
        CurrentPage: currPage + 1
      })
      that.GetBrokerageList(that.data.CurrentPage);
    }else{
      return
      }
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
  
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
  
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {
  
  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {
  
  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
  
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
  
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
  
  }
})